home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
system
/
csh4.zip
/
SHELL.DOC
< prev
next >
Wrap
Text File
|
1985-09-05
|
16KB
|
462 lines
shell.exe
command processor for ms.dos
This is yet another command.com replacement. It implements
unix-like shell commands (ls, mv, fgrep, rm, chdir, chmod) etc.
Other features include:
1. Command line expansion of ambiguous file names.
Programs invoked from shell never see '*.*' as an argument -
they see the list of all matching files in the current
directory.
2. History substitution - ala C-shell.
History substitution is a powerful means to save retyping of long
command lines.It allows you to do things like re-execute the last
command, re-execute the last command but redirect output to a
file, or execute a new command with arguments from previous
command lines. The last 20 commands are saved, and can be
reviewed by typing the 'history' command.
Previous commands can be referred to by their number, or relative
to the current command's number. Parameters from previous
commands can be seperated out and used individually.
History substitutions specifications come in two parts - the
command number specifier and the argument specifier, seperated
by a colon. The argument specifier is optional; if it is
omitted, the entire command line is specified.
<command specifier> ::= !! | !n | !-n
!! = last command
!n = nth command
!-n = command n commands before current command number
<argument specifier> ::= :[^$*] | :n | :n* | <empty>
n = number of argument (0 being the command name)
^ = first argument (i.e. argv[1])
$ = last argument
* = ^-$, or nothing if only one word on command line
n* = arguments n through $
<history subst specification> ::= <command specifier><argument specifier>
This is not as complicatated as it may appear. Here is an
example session.
0% ls *.c
*.c
foo.c bar.c
1% more foo.c
/* edit the last argument of the last command */
2% edit !!:$
/* go off and edit */
/* reference last argument of last command */
3% fgrep foo !!:$ bar.c
FOO.C : foo
BAR.C : foo
/* edit the second thru the last args of command 3 */
4% edit !3:2*
(go off and edit)
/* repeat last command */
%5 !!
(go off and edit)
/* remove the 1st argument of the command 2 before the current one */
%6 rm !-6:^
History substitution here is a compatible subset of the C-shells
history substitution facility. Cshell allows even weirder
combinations.
3. Multiple commands on one command line - Command lines are
split at semicolons.
example
%0 ls -l *.c ; make shell.exe ; exit
4. Character escapes and argument quoting - i.e. '\;' suppresses
the command parser from seeing the semicolon as a command
seperator.
Quotes are handles thusly:
1. String surrounded by single quotes are stripped of the
single quotes, and passed without wild-card expansion to the
invoked program.
2. Strings surrounded by double quotes are passed complete
with quotes to the calling program. This was done for a
version of grep that I have that accepts regular expressions
with embedded blanks within double quotes.
5. Many builtin commands.
a: b: c: cat
cd chdir chmod cls
commands copy cp copy
d: del dir e:
echo era erase error
exit f: fgrep g:
h: hist history i:
j: ls md mkdir
more mv no history popd
pushd pwd rd rm
rmdir set tee touch
y
There are many that are simply aliases, e.g. 'copy' and 'cp'
invoke the same program.
6. commands description syntax
terms used in syntax explanations :
fname ::= PC-DOS ambiguous or unambiguous file or directory name.
uname ::= unambiguous PC-DOS file or directory name
string ::= any string of printable characters of arbitrary(<512) length.
filelist ::= filename [filename .. filename]
noargs ::= no arguments at all
{arg} ::= term is optional
envstring ::= <string>=<string>
7. command syntax
drive
a: | b: | c: | d: | e: | f: | g: | h: | i: | j: <noargs>
changes default drive. If you don't have such a drive,
nothing happens.
cat
cat {<filelist>}
copies specified files to standard output. If none are
given, copies standard input to standard output
cp
cp | copy <filelist> <uname>
copies specified files to destination file or device. If
more than one file is in the file list, <uname> must be a
directory.
cd
cd | chdir <dirname>
makes <dirname> the current default directory.
chmod
chmod {-|+[rwh]*} <filelist>
change file permissions for specified files
+r, -r turn on or off read permission - i.e. hide the file.
+w, -w turn on or off write permission.
+h, -h turn on or off hidden attribute - converse of r
+a, -a turn on or off archive attribute
Note that '-r' or '+rwh' are both valid syntax for switches.
Also new permission switches are permissable between file
names with the following warning: I don't reset the masks
between file names - if you have a second batch of attribute
changes on the command line, the effect is additive. If
you're not careful, you could make a mess of a files
attributes.
If you don't specify any attribute switches, file attributes
will be set to 0, which means read,write,not hidden,not
system, not modified since last backup.
cls
cls | clear <noargs>
clears the screen and homes the cursor.
commands
commands <noargs>
prints a table of available built-in commands.
del
del
synonym for rm.
dir
dir
synonym for ls.
echo
echo <anything>
echos argument list to screen.
era
era
synonym for rm.
error
error <noargs>
prints returned value of last command to the screen.
exit
exit <noargs>
terminates execution of the shell.
fgrep
fgrep <pattern> <filel